package com.yh.serviceimpl;

import com.yh.dao.ProductDao;
import com.yh.javabean.Product;
import com.yh.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service("productService")
public class ProductServiceImpl implements ProductService {

    @Autowired
    ProductDao productDao;

    @Override
    public List<Product> findAll() {
        return productDao.selectAll();
    }

    @Override
    public List<Product> findAll(String productName) {
        return productDao.selectAByproductName(productName);
    }

    @Override
    public Product findById(int id) {
        return productDao.selectById(id);
    }

    @Override
    public void editProduct(Product product) {
        productDao.updateProduct(product);
    }

    @Override
    public void addProduct(Product product) {
        productDao.insertProduct(product);
    }

    @Override
    public void delete(int id) {
        productDao.deleteById(id);
    }

    @Override
    public void deleteMore(List<Integer> ids) {
        productDao.deleteByList(ids);
    }

    @Override
    public void deleteMore(int[] ids) {
        productDao.deleteByArray(ids);
    }
}
